import axios from 'axios';

//通用服务
var common = {};
//获取各类型订单总数、issueNum:待出行，waitAuthNum：待审批，waitPayNum：待支付
common.getOrderCount = function (success, fail) {
  axios.get('allOrderStatusList/allOrderNum.json').then(res => {
    success(res.data);
  }).catch(fail);
};


//查询我的各类型订单数据
common.getMyOrderList = function (params, success, fail) {
  axios.get('allOrderStatusList/allOrderList.json', {
    params: params
  }).then(function (rs) {
    success(rs.data);
  }).catch(fail);
};

//获取当前用户代办任务
common.getTask = function (success, fail) {
  axios.get('allOrderAndPlan/getAllBacklogs.json').then(res => {
    success(res.data)
  }).catch(fail);
};

//获取当前用户近期行程
common.getRecentTripList = function (success, fail) {
  axios.get('order/latelyOrder.json').then(res => {
    success(res.data);
  }).catch(fail);
};

//获取部门初始数据
common.getAttribution = function (success, fail) {
  axios.get('car/preCompany.json').then(res => {
    success(res.data);
  }).catch(fail);
}
//获取审批流程信息
common.getFlowApproveList = function (params, success, fail) {
  axios.get('workflow/getProcessLogs.json',{
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

common.getCarOrderList = function (params, success, fail) {
  axios.post('/car/orderList.json', params).then(res => {
    success(res.data);
  }).catch(fail);
};

common.getCityList = function (cityName, success, fail) {
  axios.get('/travel/apply/findCityByKeyword.json?keyword='+(cityName || '')).then(res => {
    success(res.data);
  }).catch(fail);
};
export default common;
